<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新品有戏商家合作平台</title>
    <script src="__JS__/jquery.js"></script>
    <link href="__CSS__/boot.css" rel="stylesheet">
    <link href="__STATIC__/layui/css/layui.css" rel="stylesheet">
    <script src="__JS__/layer/layer.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
</head>
<body>
{include file="base/header" /}
<div style="height: 5px"></div>
<button type="button" class="btn btn-info" onclick="examine()" >查看审核中的商品</button>
<div style="float: right; margin-top: 5px;margin-bottom: 5px" class="box-title ">
    <form class="form-inline" action="{:url('business/goods/index')}" method="get">
        <input type="text" name="title" placeholder="商品名称" value="<?php if(isset($title)) echo $title ?>" class="form-control" id="exampleInputEmail3" >
        <input type="submit" class="btn btn-default" value="搜索"/>
        <input type="button" onclick="res()" value="全部显示" class="btn btn-default"/>
    </form>
</div>
<table class="layui-table" style="text-align: center">
    <thead>
    <tr>
        <td>商品名称</td>
        <td>类型</td>
        <td>单价(元)</td>
        <td>图片</td>
        <td>条形码</td>
        <td>操作</td>
    </tr>
    </thead>
    <tbody>
    {foreach $result as $val}
    <tr id="del{$val.id}">
        <td>{$val.pname}</td>
        <td>{$val.category}</td>
        <td>{$val.purchaseprice}</td>
        <td><img src="__ROOT__\\{$val.image}" height="50px" width="50px"></td>
        <td>{$val.barcode}</td>
        <td>
            <button type="button" onclick="del({$val.id})" class="btn btn-danger btn-xs">删除</button>
            <button type="button" onclick="previewimage({$val.id})" class="btn btn-info btn-xs">查看图片</button>
        </td>
    </tr>
    {/foreach}
    </tbody>
</table>
{$result->render()}
</body>
<script>
    //先去显示
    function res() {
        window.location.href = "{:url('business/goods/index')}"
    }
    //删除
    function del(id) {
        layer.confirm('你确定要删除吗',{bnt:['确定','取消']},
            function () {
                $.ajax({
                    url:"{:url('business/goods/goodsdel')}",
                    data:"id="+id,
                    type:"post",
                    dataType:"json",
                    success:function (res) {
                        if(res.success){
                            layer.alert(res.success);
                            $("#del"+id).remove();
                        }
                        if(res.error){
                            layer.alert(res.error);
                        }
                    }
                });
            }
        );
    }
    //查看图片
    function previewimage(id) {
        layer.open({
            type:2,
            title:"图片",
            anim:2,
            //maxmin:true,
            area: ['500px', '400px'],
            content:"{:url('business/goods/previewimage')}?id="+id
        });
    }
    //审核的商品
    function examine() {
        window.location.href = "{:url('business/goods/examine')}"
    }
    //描述
    function introduct(id) {
        layer.open({
            type:2,
            title:"描述",
            anim:2,
            //maxmin:true,
            area: ['700px', '420px'],
            content:"{:url('business/goods/introduct')}?id="+id
        });
    }
</script>
</html>